import { createSSRApp } from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import uviewPlus from 'uview-ui-next'

export function createApp() {
  const app = createSSRApp(App)
  
  // 配置 Pinia
  const pinia = createPinia()
  pinia.use(
    createPersistedState({
      storage: {
        getItem: (key) => uni.getStorageSync(key),
        setItem: (key, value) => uni.setStorageSync(key, value)
      }
    })
  )
  
  // 使用 Pinia
  app.use(pinia)
  
  // 使用 uView
  app.use(uviewPlus)
  
  return {
    app
  }
}
